In general, a nonvolatile memory such as a flash memory is not capable of overwriting in data writing. Therefore, if writing and deletion of data are repeated, divided unnecessary regions remain undeleted. Processing to erase these unnecessary regions and gather used regions into a continuous region is called compaction. Conventional compaction processing for a semiconductor storage device is described in, for example, Jpn. Pat. Appln. KOKAI Publication No. 2008-146253 (paragraphs 0050, 0051, 0066, 0067 and 0072 to 0075).
In the storage device described in Jpn. Pat. Appln. KOKAI Publication No. 2008-146253, two-chip 8-gigabit NAND flash memories having a 16-bit input/output are connected in parallel to a 32-bit memory bus. Two chips are simultaneously accessed in parallel in reading and writing. That is, the memory bus comprises two channels of 16-bit buses. Each flash memory is accessed for writing or reading, for example, in 4-kilobyte page units. Thus, 8 kilobytes are collectively accessed as an actual page size.
A RAM incorporated in the storage device comprises a code area or working area for executing a program. The RAM further comprises an address translation table for managing page-by-page virtual addresses, a search table for searching for a normal free block, a counter table for managing the number of invalid pages in each block, a write pointer, a counter for the total number of invalid pages, and an unused page counter.
Data is updated (written) with additional writing. When data is written with the additional writing, a page region corresponding to a physical page address where data before update is stored, such as “0x0060B0” is deleted from a physical address field of the address translation table and cannot be accessed externally. That is, the page region is invalidated.
However, such regions have data written therein and in this condition, cannot even be used as free regions. If such writing is repeated many times, a great number of invalid pages are created. In order for these regions to be usable as free regions again, the data therein needs to be erased to restore the regions (corresponding to the compaction). In this case, other valid data remaining in the deletion block “0x0060” to be erased needs to be saved.
To carry out this restoration processing, for example, the valid data in the target block can be, first, once read into a page buffer as in the case of updating, and the data can be then written into a free region of another block in the additional writing so that the data is substantially saved. That is, a valid page is temporarily updated to completely invalidate its original region. The target block is then erased and the restoration processing is thus achieved.
This restoration processing can be automatically performed when the storage device is on standby or when a system is idle. However, forced restoration processing has little effect in a situation where a great number of unused regions remain and there are only a small number of invalid pages. On the other hand, if the restoration processing is not performed for a long time, there may be a shortage of unused regions leading to access latency. Therefore, a function to determine whether the restoration processing should be really executed and select a target block for the restoration processing is needed somewhere in the system.
Accordingly, the restoration processing, the determination of whether to execute the restoration processing and the selection of a restoration target block are regarded as one operation group, and are packaged in the storage device as a restoration sequence. The restoration sequence is automatically executed in response to a restoration processing execution command from a storage device itself which managed by firmware (FW), (rarely from host's command), usually it is done when the storage device is not busy or put on standby.
Thus, in the device described in Jpn. Pat. Appln. KOKAI Publication No. 2008-146253, the restoration processing, the determination of whether to execute the restoration processing and the selection of a restoration target block are packaged in the storage device as one restoration sequence, and the restoration sequence is executed in response to the restoration processing execution command from the system. As a result of the restoration of the invalid pages in the flash memory, the efficiency of the use of the flash memory can be improved.
However, since the restoration sequence is executed as software on a CPU in this device, the CPU has to perform plural processes to even execute one restoration sequence. There is a problem of decreased performance of the whole system when the processing performance of the CPU deteriorates due to interventions of the software during the execution of the restoration processing.